package fons.model.ontology.language;

public abstract class AbstractSentenceElement implements SentenceElement {
	private final Object reference;
	
	public <T> AbstractSentenceElement (T reference) {
		this.reference = reference;
	}

	public <T> boolean holds(Class<T> clazz) {
		return clazz.isInstance(reference);
	}

	public <T> T get(Class<T> clazz) {
		return clazz.cast(reference);
	}

	public final int compareTo(SentenceElement other) {
		return getPosition() < other.getPosition() ? -1 :
			getPosition() == other.getPosition() ? 0 : 1;
	}
	
	public Class<?> getReferenceClass() {
		return reference.getClass();
	}
	
	@Override
	public boolean isImplicit() {
		return false;
	}
}
